import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { HttpParams, HttpResponse } from '@angular/common/http';

export interface ApiType {
  url: string; // 接口地址
  method: HttpMethod; // http方法类型
}
export interface ApiMold {
  getInfoById?: ApiType,
  getInfoByIds?: ApiType,
  exist?: ApiType,
  list?: ApiType,
  page?: ApiType,
  add?: ApiType,
  update?: ApiType,
  delete?: ApiType,
  batchDelete?: ApiType,
  [key: string]: ApiType
}
export enum API {
  system = '/system',
  user = '/system/user',
  menu = '/system/menu',
  role = '/system/role',
  dept = '/system/dept',
  city = '/core/city',
  area = '/core/city/area',
  police = '/core/city/police',
  accessReport = '/assess/assessReport',
  permision = '/system/dept',
  assess = '/assess/assess',
  device = '/device',
  uploadFile = '/network/upload/uploadFile',
  inout = '/people/inout/record',
  house = '/core/house',
  room = '/core/room',
  info = '/people/info',
  dic = '/system/dict',
  log = '/log/',
  pay = '/pay',
  doorCard='/core',
  manager='/core/manager',
  dictionary='/core/dictionary'

}
export enum HttpMethod {
  POST = 'POST',
  GET = 'GET',
  DELETE = 'DELETE',
  PUT = 'PUT'
}
@Injectable()
export class ApiService {
   readonly login: ApiType = {
    url: API.system + '/oauth/token',
    method: HttpMethod.POST
  }
  readonly util: ApiMold = {
     uploadFile: {url: API.uploadFile, method: HttpMethod.POST}
  }
    /*
      字典接口
    */
      readonly dictionary: ApiMold = {
        page: {url: API.dictionary+'/page',method:HttpMethod.POST},
       }
   /**
   * 卡管理接口
   */
    readonly doorCard: ApiMold = {
      save: {url: API.doorCard + '/door/card/save', method: HttpMethod.POST},
      list: {url: API.doorCard + '/door/card/uzzySearch', method: HttpMethod.POST},
      searchPer: {url: API.doorCard + '/person/queryPersonRoomInfo', method: HttpMethod.POST},
      queryInfo: {url: API.doorCard + '/door/card/peopleCardInfo', method: HttpMethod.POST},
      bindingCardAndPay:{url:API.doorCard + '/door/card/bindingCardAndPay', method: HttpMethod.GET},
      queryPeopleCardInfo:{url:API.doorCard + '/door/card/queryPeopleCardInfo', method: HttpMethod.GET},
      checkCard:{url:API.doorCard + '/door/card/', method: HttpMethod.GET},
      reapplyCard:{url:'/core/person/reapplyCard',method:HttpMethod.POST},
      cancelCard:{url:"/core/person/cancelCard",method:HttpMethod.POST},
      freezeCard:{url:"/core/person/freezeCard",method:HttpMethod.POST},
      unFreezeCard:{url:"/core/person/unFreezeCard",method:HttpMethod.POST},
      relocateHouse:{url:"/core/person/relocateHouse",method:HttpMethod.POST},
      desCard:{url:API.doorCard + '/door/card/desCard',method:HttpMethod.POST}
    }

    /*
      告警管理接口
    */
   readonly alarmManage: ApiMold = {
    abnormalpage: {url: "/core/person/abnormalpage",method:HttpMethod.POST},
    devicePage: {url: "/core/event/devicePage",method:HttpMethod.POST}
   }

   /**
   * 支付管理接口
   */
    readonly pay: ApiMold = {
     arealist: {url: '/core/city/area/findAreaItem', method: HttpMethod.POST},
     itemList: {url: API.pay + '/item', method: HttpMethod.GET},
     add: {url: API.pay + '/item', method: HttpMethod.POST},
     //delete: {url: API.menu + '/cancel', method: HttpMethod.PUT},
     update: {url: API.pay + '/item', method: HttpMethod.PUT},
     payList: {url: '/core/pay/findPayList', method: HttpMethod.POST},
     payStatistics:{url:'/core/pay/payStatistics',method:HttpMethod.POST},
     incomeStatistics:{url:'/core/pay/incomeStatistics',method:HttpMethod.POST},
     cancelPay:{url:"/core/pay/cancelPay",method:HttpMethod.POST}
   }
  /*
   房东管理接口
  */
   readonly manager: ApiMold = {
     queryLndlordList: {url:API.manager + '/queryLndlordList',method: HttpMethod.POST },
     queryUnitHouse: {url:'/core/city/area/queryUnitHouse',method:HttpMethod.POST},
     landlordRegister: {url: '/core/person/landlordRegister', method:HttpMethod.POST},
     landlordBingdingCard:{url: '/core/person/landlordBingdingCard',method:HttpMethod.POST},
     landlordManageUnitList:{url:'/core/manager/landlordManageUnitList',method:HttpMethod.POST},
     manageUnit:{url:'/core/manager/manageUnit',method:HttpMethod.POST}
   }
  /**
   * 用户管理
   */
   readonly user: ApiMold = {
    getInfoById: {url: API.user + '/', method: HttpMethod.GET},
    list: {url: API.user + '/list', method: HttpMethod.POST},
    page: {url: API.user + '/page', method: HttpMethod.POST},
    detail: {url: API.user + '/details', method: HttpMethod.POST},
    add: {url: API.user + '/save', method: HttpMethod.POST},
    update: {url: API.user + '/update', method: HttpMethod.PUT},
    delete: {url: API.user + '/cancel', method:HttpMethod.PUT},
     resetPassword: {url: API.user + '/resetPassword', method: HttpMethod.PUT},
     info: {url: API.user + '/user', method: HttpMethod.GET},
     changePwd: {url: API.user + '/changePassword', method: HttpMethod.PUT},
     updatePerson: {url: '/core/person/update',method:HttpMethod.POST},
     userSurrender: { url : '/core/person/userSurrender', method: HttpMethod.POST}
  }

  readonly OPSAssess: ApiMold = {
    getInfoById: {url: '', method: HttpMethod.GET},
    list: {url: '', method: HttpMethod.POST},
    page: {url: '', method: HttpMethod.POST},
    add: {url: '', method: HttpMethod.POST},
    update: {url: '', method: HttpMethod.PUT},
    delete: {url: '', method:HttpMethod.DELETE},
    batchDelete: {url: '', method: HttpMethod.POST}
  }
  /**
   * 菜单管理接口
   */
  readonly menu: ApiMold = {
     page: {url: API.menu + '/page', method: HttpMethod.POST},
    list: {url: API.menu + '/list', method: HttpMethod.POST},
    add: {url: API.menu + '/save', method: HttpMethod.POST},
    delete: {url: API.menu + '/cancel', method: HttpMethod.PUT},
    update: {url: API.menu + '/update', method: HttpMethod.PUT}
  }
  /**
   * 城市管理
   */
  readonly city: ApiMold = {
    page: {url: API.city + '/page', method: HttpMethod.POST},
    tree: {url: API.city + '/findIdAndCity', method: HttpMethod.POST},
    allTree: {url: API.city + '/findAllCity', method: HttpMethod.POST},
    add: {url: API.city, method: HttpMethod.POST},
    update: {url: API.city, method: HttpMethod.PUT},
    delete: {url: API.city, method: HttpMethod.DELETE},
    list: {url: API.city + '/list', method: HttpMethod.POST}
  }
  /**
   * 区域管理
   */
  readonly area: ApiMold = {
    getInfoById: {url: API.area, method: HttpMethod.GET},
    page: {url: API.area + '/page', method: HttpMethod.POST},
    tree: {url: API.area + '/getAreaAllListForId', method: HttpMethod.POST},
    add: {url: API.area, method: HttpMethod.POST},
    update: {url: API.area, method: HttpMethod.PUT},
    delete: {url: API.area + '/batch/delete', method: HttpMethod.DELETE},
    list: {url: API.area + '/list', method: HttpMethod.POST},//检查用户新增按钮权限
    details: {url: API.area + '/details', method: HttpMethod.POST},//检查用户编辑按钮权限
    treeList: {url: API.area + '/treeList', method: HttpMethod.POST},
    queryList:{url:API.area + '/queryList',method:HttpMethod.POST},
    addDoor:{url:'/core/area/host/addDoor',method:HttpMethod.POST},
    doorPage:{url:'/core/area/host/page',method:HttpMethod.POST},
    doorDel:{url:'/core/area/host',method:HttpMethod.POST},
  }
  /**
   * 警务区管理
   */
  readonly police: ApiMold = {
    page: {url: API.police + '/page', method: HttpMethod.POST},
    tree: {url: API.police + '/getAreaAllListForId', method: HttpMethod.POST},
    add: {url: API.police, method: HttpMethod.POST},
    update: {url: API.police, method: HttpMethod.PUT},
    delete: {url: API.police+'/batch/cancel', method: HttpMethod.PUT},
    list: {url: API.police, method: HttpMethod.GET}
  }
  /**
   * 考核报表
   */
  readonly accessReport: ApiMold = {
    page: {url: API.accessReport + '/page', method: HttpMethod.POST},
    importExcel: {url: API.accessReport + '/importAndCalcWorkAssess', method: HttpMethod.POST},
    exportExcel: {url: API.accessReport + '/exportDetail', method: HttpMethod.POST}
  }
  /**
   * 部门
   */
  readonly permision: ApiMold = {
    page: {url: API.permision + '/page', method: HttpMethod.POST},
    list: {url: API.permision + '/list', method: HttpMethod.POST},
    add: {url:API.permision + '/save', method: HttpMethod.POST},
    update: {url: API.permision +'/update', method: HttpMethod.PUT},
    delete: {url: API.permision + '/cancel', method: HttpMethod.PUT}
  }
  /**
   * 角色管理
   */
  readonly  role: ApiMold = {
    page: {url: API.role + '/page', method: HttpMethod.POST},
    list: {url: API.role + '/list', method: HttpMethod.POST},
    add: {url: API.role + '/save', method: HttpMethod.POST},
    update: {url: API.role + '/update', method: HttpMethod.PUT},
    delete: {url: API.role + '/cancel', method: HttpMethod.PUT}
  }
  /**
   * 字典管理
   */
  readonly dic: ApiMold = {
    page: {url: API.dic + "/page", method: HttpMethod.POST},
    list: {url: API.dic + "/list", method: HttpMethod.POST},
    add: {url: API.dic + "/save", method: HttpMethod.POST},
    delete: {url: API.dic + "/cancel", method: HttpMethod.PUT},
    update: {url: API.dic + "/update", method: HttpMethod.PUT},
    getDic: {url: API.dic + '/list/', method: HttpMethod.GET}
  }
  /**
   * 日志管理
   */
  readonly Log: ApiMold = {
    operateLog: {url: API.log + 'operation/page', method: HttpMethod.POST},
    serviceLog: {url: API.log + 'movement/page', method: HttpMethod.POST},
    sysLog: {url: API.log + 'service/page', method: HttpMethod.POST}
  }
  /**
   * 获取用户列表
   */
  userList: ApiType = {
    url: API.user + '/page',
    method: HttpMethod.POST
  }
  /**
   * 运维考核统计和审核
   */
  assess: ApiMold = {
    statistics: {url: API.assess + '/getStatistics', method: HttpMethod.POST},
    applyReduction: {url: API.assess + '/applyReduction', method: HttpMethod.POST},
    applyReductionBatch: {url: API.assess + '/applyReductionBatch', method: HttpMethod.POST},
    inoutStatistic: {url:  '/assess/inout/statistic/page', method: HttpMethod.POST}
  }
  /**
   * 设备
   */
  device: ApiMold = {
    offLinePage: {url: API.device + '/offline/listOfflineDevice', method: HttpMethod.POST},
    pointPage: {url: API.device + '/device/listPointInfo', method: HttpMethod.POST},
    listByHouseId: {url: API.device + '/device/findDeviceInfoByHouse', method: HttpMethod.POST},
    page: {url: API.device + '/house/deviceInfoList', method: HttpMethod.POST},
    issueTime: {url:"/core/host/issueTime",method:HttpMethod.POST}
  }
  /**
   * 出入记录
   */
  inout: ApiMold = {
    page: {url: API.inout + '/page', method: HttpMethod.POST},
    detail: {url: API.inout + '/queryInoutPeopleDetail', method: HttpMethod.POST}
  }
  /**
   * 房屋管理
   */
  house: ApiMold = {
    page: {url: API.house + '/page', method: HttpMethod.POST},
    list: {url: API.house + '/list', method: HttpMethod.POST},
    add: {url: API.house, method: HttpMethod.POST},
    update: {url: API.house, method: HttpMethod.PUT},
    getInfoById: {url: API.house, method: HttpMethod.GET},
    batchDelete: {url: API.house, method: HttpMethod.POST},
    peopleRegister: {url: "/core/person/peopleRegister", method: HttpMethod.POST}
  }
  /**
   * 房间管理
   */
  room: ApiMold = {
    page: {url: API.room + '/page', method: HttpMethod.POST},
    list: {url: API.house + '/list', method: HttpMethod.POST},
    add: {url: API.room, method: HttpMethod.POST},
    update: {url: API.room, method: HttpMethod.PUT},
    getInfoById: {url: API.room + '/findRoomAndPerson', method: HttpMethod.POST},
    addPerson: {url: API.room + '/person', method: HttpMethod.POST},
    delete:{url:API.room+'/batch/delete',method:HttpMethod.POST}
  }
  /**
   * 人员信息
   */
  peopleInfo: ApiMold = {
    page: {url: API.info + '/page', method: HttpMethod.POST},
    managerPage: {url: '/people/manager/page', method: HttpMethod.POST},
    cardList: {url: '/people/doorcard/getDoorCardInfo', method: HttpMethod.GET},
    statistics: {url: API.info + '/countInfoByHouseId', method: HttpMethod.GET},
    cardStatistics: {url: API.info + '/queryPeopleAndCardCount', method: HttpMethod.POST},
    focusPersonnel: {url: '/people/police/info/page', method: HttpMethod.POST}
  }
  dept: ApiMold = {
    page: {url: API.dept + '/page', method: HttpMethod.POST},
    list: {url: API.dept + '/list', method: HttpMethod.POST},
    add: {url: API.dept + '/save', method: HttpMethod.POST},
    update: {url: API.dept + '/update', method: HttpMethod.PUT},
    delete: {url: API.dept + '/cancel', method: HttpMethod.PUT}
  }

   request(url: string, method: HttpMethod, param: string = null, body: any): Observable<HttpResponse<any>> {
    return
  }

}

